//路由配置
(function() {
var Config = APM.Config = createApp("config");

Config.routerMap(function() {
	this.route("sysbasic");
	
	this.route("packetfilterface",{path:"/:packetfilterface_id"},function(){
		this.route("packetfilter")
	});
	this.route("globalalarms");
	this.route("position");
	this.route("modulel7");
	this.route("usermanage");
	this.route("history");
	this.route("logs");
	this.route("pcap");
	this.route("iprepair");
	this.route("sysinfo");
	this.route("agreement");
	/*this.route("nodes", function(){
		this.route("topo");
	});*/
	this.route("test");
//	this.route("cluster");
//	this.route("integrated");
//	this.route("service");
//	this.route("sysmonitor",function(){
//		this.route("system");
//		this.route("protocol");
//		this.route("indicator");
//		this.route("database");
//	});
//	this.route("confmanage");
//	this.route("sysupgrade");
//	this.route("system");
});

APM.ConfigRoute = Config.Route.extend({
	templates: [
		{
			name: "main/frame",
			url: "/apps/main/tpls/main_frame.hbs"
		},
		"config"
	],

	dependences: [
		"/apps/main/ctrls/frame_ctrl",
		"/apps/main/views/frame_view",
	],

	renderTemplate: function(){
		this.render("main/frame", {controller: "mainFrame", view: "mainFrame"});
		this.render("config", {into: "main/frame"});
	}
});

APM.ConfigIndexRoute = Config.Route.extend({
	redirect : function() {
		this.transitionTo("config.sysbasic");
	}
});

APM.ConfigTestRoute = Config.Route.extend({
	dependences: [
		"./ctrls/test_ctrl",
		"apm/ui/formtip",
		"broada/ui/combobox",
		"broada/ui/inputdate"
	],
	actions: {
		willTransition: function(){
			this.controller.send("reset");
		}
	}
});

// 基本配置
APM.ConfigSysbasicRoute = Config.Route.extend({
	dependences : [
		"./ctrls/sysbasic_ctrl",
		"apm/ui/formtip"
	],
	actions: {
		willTransition: function(){
			this.controller.send("reset");
		}
	},

	setupController: function(ctrl, params, transition){
		ctrl.initConfData();
	},
	actions: {
		willTransition: function(){
			this.controller.send("reset");
		}
	},
});

// 数据包过滤规则配置
APM.ConfigPacketfilterfacePacketfilterRoute = Config.Route.extend({
	dependences : [
		"./ctrls/packetfilterface_packetfilter_ctrl",
		"./views/packetfilterface_packetfilter_view"
	],
	actions: {
		willTransition: function(){
			this.controller.send("reset");
		}
	},
	setupController: function(ctrl, model, transition){
		ctrl.set("model",model);
		ctrl.initConfData();
		ctrl.currentIp();
	}
});

// 数据包过滤规则父级配置
APM.ConfigPacketfilterfaceRoute = Config.Route.extend({
	dependences : [
		"./ctrls/packetfilterface_ctrl",
		"./views/packetfilterface_view"
	],
	model: function(params, transition){

		return {"id":params.packetfilterface_id};
	},
	setupController: function(ctrl, model, transition){
		console.log(ctrl);
		console.log(model.id);
	}
});

// 数据包过滤规则父级跳转到数据包过滤规则配置
APM.ConfigPacketfilterfaceIndexRoute = Config.Route.extend({
	redirect: function() {
		this.transitionTo("config.packetfilterface.packetfilter");
	}
});

// 全局告警条件配置
APM.ConfigGlobalalarmsRoute = Config.Route.extend({
	dependences : [ "./ctrls/globalalarms_ctrl", "apm/ui/formtip" ],
	actions: {
		willTransition: function(){
			this.controller.send("reset");
		}
	},

	setupController: function(ctrl, params, transition){
		ctrl.initConfData();
	}
});

// 地理位置配置
APM.ConfigPositionRoute = Config.Route.extend({
	dependences : [
		"./ctrls/position_ctrl",
		"./views/position_view"
	],
	actions: {
		willTransition: function(){
			this.controller.send("reset");
		}
	},

	setupController: function(ctrl, params, transition){
		//ctrl.initConfData();
	}
});

// L7模块配置
APM.ConfigModulel7Route = Config.Route.extend({
	dependences : [
		"./ctrls/modulel7_ctrl",
		"./views/modulel7_view"
	],
	actions: {
		willTransition: function(){
			this.controller.send("reset");
		}
	},

	setupController: function(ctrl, params, transition){
		ctrl.initConfData();
	}
});

// 全部协议
APM.ConfigAgreementRoute = Config.Route.extend({
	dependences : [
		"./ctrls/agreement_ctrl",
		"./views/agreement_view"
	],
	actions: {
		willTransition: function(){
			// this.controller.send("reset");
		}
	},

	setupController: function(ctrl, params, transition){
		ctrl.requireAgreementList();
	}
});

//用户管理配置
APM.ConfigUsermanageRoute = Config.Route.extend({
	dependences : [
		"./ctrls/usermanage_ctrl",
		"./views/usermanage_view"
	],
	actions: {
		willTransition: function(){
			this.controller.send("reset");
		}
	},

	setupController: function(ctrl, params, transition){
		ctrl.initConfData();
	}
});

// 历史数据配置
APM.ConfigHistoryRoute = Config.Route.extend({
	dependences: [ 
		"./ctrls/history_ctrl",
		"./views/history_view"
	],
	actions: {
		willTransition: function(){
			this.controller.send("reset");
		}
	},

	setupController: function(ctrl, params, transition){
		ctrl.initConfData();
	}
});

// 日志查看
APM.ConfigLogsRoute = Config.Route.extend({
	dependences : [
		"./ctrls/logs_ctrl"
	],
	setupController: function(ctrl){
		ctrl.requireData();
	}
});

// 样本包
APM.ConfigPcapRoute = Config.Route.extend({
	dependences : [
		"./ctrls/pcap_ctrl"
	],
	setupController: function(ctrl){
		ctrl.requireData();
	}
});

//IP地理位置库维护
APM.ConfigIprepairRoute = Config.Route.extend({
	dependences : [
		"./ctrls/iprepair_ctrl",
		"./views/iprepair_view"
	],
	actions: {
		willTransition: function(){
			this.controller.send("reset");
		}
	},

	setupController: function(ctrl, params, transition){
		ctrl.initConfData();
	}
});

//系统信息
APM.ConfigSysinfoRoute = Config.Route.extend({
	dependences : [
		"./ctrls/sysinfo_ctrl",
		"./views/sysinfo_view"
	],
	setupController: function(ctrl, model){
		ctrl.requireSysinfo();
		ctrl.startRealTimeMode();
	},
	deactivate: function(){
		this.controller.stopRealTimeMode();
	}
});

/*APM.ConfigNodesIndexRoute = Config.Route.extend({
	redirect: function() {
		this.transitionTo("config.nodes.topo");
	}
});*/

/*APM.ConfigNodesTopoRoute = Config.Route.extend({
	dependences : [
		"./ctrls/nodes_topo_ctrl",
		"./views/nodes_topo_view"
	],

	model: function(){
		var nodesPromise = this.store.ajax("GET", "nodes")
		.then(function(response){
			var nodes = Ember.A(response.nodes);
			nodes.forEach(function(node){
				node.name = node.name || (node.ip + ':' + node.port);
			});
			return nodes;
		});
		var relationsPromise = this.store.ajax("GET", "relations/discovery")
		.then(function(response){
			return Ember.A(response.relations);
		});
		return Ember.RSVP.hash({
			nodes: nodesPromise,
			relations: relationsPromise
		});
	}
});*/


// 集成配置
//APM.ConfigIntegratedRoute = Config.Route.extend({
//	dependences : [ "./ctrls/integrated_ctrl", "apm/ui/formtip" ,"broada/ui/combobox"],
//	actions: {
//		willTransition: function(){
//			this.controller.send("reset");
//		}
//	}
//});

//// 服务器配置
//APM.ConfigServiceRoute = Config.Route.extend({
//	dependences : [ "./ctrls/service_ctrl", "apm/ui/formtip","broada/ui/combobox","broada/ui/inputdate"],
//	actions: {
//		willTransition: function(){
//			this.controller.send("reset");
//		}
//	}
//});

// 集群配置
//APM.ConfigClusterRoute = Config.Route.extend({
//	dependences : [ "./ctrls/cluster_ctrl", "apm/ui/formtip","broada/ui/dialog"  ],
//	actions: {
//		willTransition: function(){
//			this.controller.send("reset");
//		}
//}
//});

//// 系统监控
//APM.ConfigSysmonitorRoute = Config.Route.extend({
//	dependences : [ "./ctrls/sysmonitor_ctrl", "apm/ui/formtip"],
//	redirect: function() {
//		this.transitionTo("config.sysmonitor.system");
//	}
//});
//
//// 配置管理
//APM.ConfigConfmanageRoute = Config.Route.extend({
//	dependences : [ "./ctrls/confmanage_ctrl", "apm/ui/formtip" ],
//	actions: {
//		willTransition: function(){
//			this.controller.send("reset");
//		}
//	}
//});
//
//// 系统升级
//APM.ConfigSysupgradeRoute = Config.Route.extend({
//	dependences : [ "./ctrls/sysupgrade_ctrl", "apm/ui/formtip" ],
//	actions: {
//		willTransition: function(){
//			this.controller.send("reset");
//		}
//	}
//});
//
////系统监控—操作系统
//APM.ConfigSysmonitorSystemRoute = Config.Route.extend({
//	dependences : [ "./ctrls/sysmonitor_system_ctrl", "apm/ui/formtip"]
//});
//
////系统监控—协议分析器
//APM.ConfigSysmonitorProtocolRoute = Config.Route.extend({
//	dependences : [ "./ctrls/sysmonitor_protocol_ctrl", "apm/ui/formtip"]
//});
//
////系统监控—指标运算服务
//APM.ConfigSysmonitorIndicatorRoute = Config.Route.extend({
//	dependences : [ "./ctrls/sysmonitor_indicator_ctrl", "apm/ui/formtip"]
//});
//
////系统监控—数据库
//APM.ConfigSysmonitorDatabaseRoute = Config.Route.extend({
//	dependences : [ "./ctrls/sysmonitor_database_ctrl", "apm/ui/formtip"]
//});
})();